package com.xh.common.thread.ext.executor;

import java.util.concurrent.TimeUnit;

public class LevelConfig {

    public final int mCorePoolSize;
    public final int mMaximumPoolSize;
    public final long mKeepAliveTime;
    public final boolean mAllowCoreThreadTimeOut;

    public LevelConfig(int corePoolSize, int maximumPoolSize, long keepAliveTime, TimeUnit unit, boolean allowCoreThreadTimeOut) {
        mCorePoolSize = corePoolSize;
        mMaximumPoolSize = maximumPoolSize;
        mKeepAliveTime = unit.toNanos(keepAliveTime);
        mAllowCoreThreadTimeOut = allowCoreThreadTimeOut;

        if (corePoolSize < 0 ||
                maximumPoolSize <= 0 ||
                maximumPoolSize < corePoolSize ||
                keepAliveTime < 0)
            throw new IllegalArgumentException();
    }
}
